package com.company.cloud.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.company.cloud.web.service.WebArtService;
import com.company.cloud.web.service.WebIndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.Map;

/**
 *  艺术机构
 * */
@Controller
@RequestMapping("/organ")
public class OrganController {

    @Autowired
    private WebIndexService webIndexService;

    @Autowired
    private WebArtService webArtService;

    /**
     * 艺术机构列表
     * */
    @RequestMapping("/query")
    public String query(Model model,@RequestParam Map<String,String> params,@CookieValue(value="org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE" ,defaultValue = "zh-CN") String i18n){
        System.out.println("++++++++++++ CompanyController:query");
        JSONObject data= webArtService.organQuery(params);

        model.addAttribute("data",data);
        return "organ/detail";
    }


    /**
     * 艺术机构详细信息
     * */
    @RequestMapping("/detail")
    public String detail(Model model, String organNo,@CookieValue(value="org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE" ,defaultValue = "zh-CN") String i18n){
        System.out.println("++++++++++++ CompanyController:detail");
        JSONObject data= webArtService.organInfo(organNo);
        model.addAttribute("data",data);
        return "organ/detail";
    }

}
